package org.lib.rabbitmqhello.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
	
	public final static String QUEUE_1 = "queue1";
	public final static String EXCHANGE_1 = "ex1";
	
	@Bean
	public Queue queue1() {
		Queue queue1 = new Queue(QUEUE_1);
		return queue1;
	}
	
	@Bean
	public DirectExchange directExchange1() {
		return new DirectExchange(EXCHANGE_1);
	}
	
	@Bean
	public Binding binding1(Queue queue1, DirectExchange directExchange1) {
		return BindingBuilder
				.bind(queue1)
				.to(directExchange1)
				.withQueueName();
	}
	
}
